<%@page import="com.is.util.Common"%>
<%@page import="com.is.util.DesData"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="com.is.util.ParamUtil"%>
<%@page import="java.util.List"%>
<%@page import="com.is.control.CourseClassControl"%>
<%@page import="com.is.model.User"%>
<%@page import="com.is.control.ParamClassControl"%>
<%@page import="com.is.model.CourseClass"%>
<%@page import="com.is.model.ParamReasonType"%>
<%@page import="com.is.control.ParamReasonTypeControl"%>
<%@page import="com.is.model.Student"%>
<%@page import="com.is.control.StudentControl"%>
<%@page import="com.is.control.ParamStuyearControl"%>
<%@page import="com.is.util.DateTime"%>
<%@page import="com.is.control.ParamCourseControl"%>
<%@page import="com.is.servlet.TokenProcessor"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="/InterStu/resources/image/favicon.ico" />
<link rel="stylesheet" type="text/css" href="../../resources/css/all.css" />
<script type="text/javascript" src="../../resources/js/jquery-1.8.1.js"></script>
<link href="../../resources/css/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../resources/js/jquery.artDialog.js"></script>
<script type="text/javascript" src="../../resources/js/iframeTools.js"></script>
<script type="text/javascript" src="../../resources/js/WebCalendar.js"></script>
<script type="text/javascript">
	$(function(){
		var block = $("#magic_block");
		if($(".active a").position()){
			block.css("top",$(".active a").position().top+10)
			.data("oriTop",$(".active a").position().top)
		}
		$(".nav ul li").find("a").hover(
			function(){
				var $this = $(this);
				var newTop = $this.position().top;
				block.stop().animate({
					top:newTop+10
				})
			},
			function(){
				block.stop().animate({
					top:block.data("oriTop")+10
				})
			}
		)
		var h = $(".right").height();
		$(".left").height(h);
		$(".update").click(function(){
			$.dialog.open("/InterStu/update_info.jsp",{width:460,height:400,title:"个人信息"});
		})
		$('img').error(function(){
			this.src = "/InterStu/resources/image/man.GIF";
		})
	})
	
	
	function doSubmit(){
      var submit = document.getElementById("submit");
      submit.disabled="disabled";
      return true;
}
      $(function(){
			$("input[name='dm']").click(function(){
					document.forms['as'].action="attendance_add.jsp";
					document.forms['as'].submit();
			})
			$("input[name='cq']").click(function(){
					document.forms['as'].action="attendance_statistics.jsp";
					document.forms['as'].submit();
			})

       })
	
</script>
<script type="text/javascript">

</script>
<title>留学生预科班</title>
</head>
<%
             //此页面需要的参数courseId
             User cu =(User)session.getAttribute("user"); 
             int stuyear=ParamStuyearControl.getCurrentStuyearId();  //此处需要改为自动获取当前学年
             int uid = cu.getRole().equals("1")?0:cu.getId();
             int courseClassId = ParamUtil.getInt(request,"courseClassId",0);
             List<CourseClass> ccs = CourseClassControl.getAllCourseClassIdByUidAndStuyear(uid,stuyear);
             ccs = Common.sortCourseClassName(ccs);  //对班级+课程名排序
             if(ParamUtil.getInt(request,"courseClassId",0)!=0){
            	 session.setAttribute("ccid",ParamUtil.getInt(request,"courseClassId"));
             }
             int ccid=-1;
             if(session.getAttribute("ccid")!=null){
            	  ccid = Integer.parseInt(session.getAttribute("ccid")+"");
             }
             String time= DateTime.SimpleDate();
%>
<body>
<div class="header">
	<div class="title pr">
    	<a href="javascript:void(0);"><span class="update pa">个人信息</span></a>
        <span class="logout pa"><a class="hide" href="/InterStu/login/logout.jsp">退出</a></span>
    </div>
</div>
<div class="main">
	<div class="left"> 
	    <div class="infomation">
			<div class="photo">
			<%
			String picUrl = cu.getPicUrl();
			%>
				<img width='60' height="60" src = "<%=picUrl %>"   />
			</div>
			<div class="welcome">
				<%=cu.getName() %>,<br/>
				欢迎您使用！
			</div>
		</div>  	   	  	 	
    	<div class="nav">
        	<ul>	
        		<li class="pa" id="magic_block"></li>
            	<%if(cu!=null&&cu.getRole().equals("1")){ %>
                <li><a href="/InterStu/pages/stuyear/stuyear_start.jsp">新学期设置</a></li>
                <li><a href="/InterStu/pages/users/user_all.jsp">用户管理</a></li>
                <%} %>
                <li class="active"><a href="/InterStu/pages/students/student_add.jsp">学生管理</a></li>
                <li ><a href="/InterStu/pages/dictation/dictation_add.jsp">学生考核</a></li>
                <%if(cu!=null&&cu.getRole().equals("1")){ %>
                <li><a href="/InterStu/pages/assess/teacher_assess.jsp">教职人员管理</a></li>
                <%} %>
            </ul>
        </div>
    </div>
    <div class="right">
    	<div class='r1'>
    	<table class="student tab">
    <tr>
    <%if(cu!=null&&cu.getRole().equals("1")){ %>
    	<td>
    		<a href="/InterStu/pages/students/student_add.jsp">添加学生</a>
		</td>
		<%} %>
		<td>
			<a href="/InterStu/pages/students/student_admin.jsp?id=<%=cu.getId() %>">查看学生</a>
		</td>
		<td>
			<a class='current' href="/InterStu/pages/attendance/attendance_add.jsp">学生出勤</a>
		</td>
    </tr>
    </table>
    		<form name="as" action="" method="post">
    		<table  class='table'>
    			<caption>请选择<%if(cu.getRole().equals("1")){ %><a href="oneClassAllAttendance.jsp">【查询班级出勤详细】</a><%} %></caption>
    			<tr>
    				<td>选择点名的课程</td>
    				<td>课程班级</td>
    				<td><select name="courseClassId">
							<% 
					             for(CourseClass c:ccs){//可能一个任课老师有多个班级
					            	 %>
					            	 <option value="<%=c.getId() %>" <%if(c.getId()==ccid) out.print("selected='selected'"); %>><%=ParamClassControl.getClassName(c.getClassId())%><%=ParamCourseControl.getCourseById(c.getCourseId()).getCourseName() %></option> 
					            	 <%
					             }
							%>
						</select>
					</td>
    				<td><input type="button" value="进入点名"  name="dm"  /></td>
    				<td><input type="button" value="查看出勤情况"" name="cq"/></td>
    			</tr>
    		</table>
			</form>
		</div>
		
		<%
		  if(courseClassId>0){
			  CourseClass nowc = CourseClassControl.getCourseClassById(courseClassId);
		%>
		<div class='r2'>
			<form action="attendance_add_do.jsp" method="post" onsubmit="return doSubmit()">
			<table class='table'>
			<caption>请选择</caption>
			<thead>
			<tr>
			<th>姓名</th>
			<th  colspan="5">出勤情况</th>
			</tr>
			</thead>
			<tbody>
			<%
				//System.out.print("DDDD"+nowc.getClassId()+"DDDD");
                List<Student> students = StudentControl.getAllStudentMulti("","","",nowc.getClassId()+"","","","","");
                int mark=0; 
			  	for(Student s:students){
					   %>
					   <tr>
					   <td><%=s.getChineseName() %>(<%=s.getPassportName() %>)</td>
					   <%
				 List<ParamReasonType> rs2 = ParamReasonTypeControl.getAllReaons();
				 for(ParamReasonType p:rs2){
					 //resonType为1固定为正常!!!!!!!!!!!!!!!!!!!!!!!!
				 	%>
				 	<td><%=p.getReasonType() %><input type="radio"  name="state<%=mark%>" value="<%=p.getId() %>" <%if(p.getId()==1) out.print("checked"); %>/></td>
				 	<%
				 }
				%>
				<td>
				<input type="hidden" value="<%=s.getId() %>"  name="student<%=mark %>"/></td>
					   </tr>
					   <%
					    mark++;
			}
			%>
			<tr>
			<td>点名时间<input id="time" type='text'  name="time" onclick="SelectDate(this,'','','yyyy-MM-dd')"  readonly style="width:80px;cursor:pointer" value="<%=time %>" /></td>
			<td colspan="5">
			<input type="hidden" value="<%=students.size() %>" name="size"/>
			<input type="hidden" value="<%=nowc.getCourseId() %>" name="scourseId"/>
			<input type="hidden" value="<%=nowc.getStuyear() %>" name="stuyear"/>
			<input type="hidden" value="<%=nowc.getId() %>" name="ccid" />
			<input type="hidden" name="token" value="<%=TokenProcessor.generateToken(request,response)%>"/>
			<input type="submit" value="提交"/></td></tr>
			</tbody>
			</table>
			</form>
		</div>
		<%}else{
			out.print("<div align='center'>请先选择点名的课程</div>");
		} %>
    </div>
</div>
<div class="footer">
	<p>版权所有：东北师范大学留学生预科部&nbsp;&nbsp;  蓝旭工作室开发</p>
</div>
</body>
</html>